import { observer } from 'mobx-react-lite'
import { useRootStore } from '../store'

function Counter () {
  // 通过useContext使用rootStore
  const { counterStore } = useRootStore()
  const { count, increment, decrement } = counterStore
  return (
    <div>
      <button onClick={() => increment()}>increment</button>
      <span>{ count }</span>
      <button onClick={() => decrement()}>decrement</button>
    </div>
  )
}
// 需要使用observer包裹
export default observer(Counter)